﻿using AutoMapper;
using Mes.Application.DTO.Inputs.MasterData;
using Mes.Application.DTO.Inputs.Operations;
using Mes.Application.DTO.Inputs.Quality;
using Mes.Application.DTO.Inputs.WorkOrders;
using Mes.Application.DTO.Results.MasterData;
using Mes.Application.DTO.Results.Operations;
using Mes.Application.DTO.Results.Quality;
using Mes.Application.DTO.Results.WorkOrders;
using Mes.Domain.BoundedContext;
using Mes.Domain.BoundedContext.Entities.MasterData;
using Mes.Domain.BoundedContext.Entities.Operations;
using Mes.Domain.BoundedContext.Entities.Quality;
using Mes.Domain.BoundedContext.Entities.WorkOrders;

namespace Mes.Application.AutoMapper
{
    public class CustomProfile : Profile
    {
        public CustomProfile()
        {
            #region global/common
            CreateMap(typeof(List<>), typeof(ItemsData<>), MemberList.None)
               .ForMember(nameof(ItemsData<object>.Items), opt => opt.MapFrom(src => src));

            CreateMap(typeof(List<>), typeof(ItemsResult<>), MemberList.None)
                .ForMember(nameof(ItemsResult<object>.Items), opt => opt.MapFrom(src => src));

            CreateMap(typeof(Paged<>), typeof(PagedItemsData<>), MemberList.None);
            #endregion

            #region MeasuringUnitType
            CreateMap<MeasuringUnitTypeInput, MeasuringUnitType>();
            CreateMap<MeasuringUnitType, MeasuringUnitTypeResult>();
            #endregion

            #region MaterialClassType
            CreateMap<MaterialClassTypeInput, MaterialClassType>();
            CreateMap<MaterialClassType, MaterialClassTypeResult>();
            #endregion

            #region MeasuringUnit
            CreateMap<MeasuringUnitInput, MeasuringUnit>();
            CreateMap<MeasuringUnit, MeasuringUnitResult>();
            #endregion

            #region ProductionUnitType
            CreateMap<ProductionUnitTypeInput, ProductionUnitType>();
            CreateMap<ProductionUnitType, ProductionUnitTypeResult>();
            #endregion

            #region MaterialClass
            CreateMap<AddMaterialClassInput, MaterialClass>();
            CreateMap<MaterialClass, MaterialClassResult>();
            #endregion

            #region Material
            CreateMap<AddMaterialInput, Material>();
            CreateMap<Material, MaterialResult>();
            CreateMap<Material, MaterialResults>();
            CreateMap<Material, MaterialsResults>();
            CreateMap<MaterialBOM, IdNameResult>();
            CreateMap<Material, IdNameResult>();
            #endregion

            #region MaterialBOM
            CreateMap<AddMaterialBOMInput, MaterialBOM>();
            CreateMap<MaterialBOM, MaterialBOMResult>();
            #endregion

            #region ProductionUnit
            CreateMap<ProductionUnitInput, ProductionUnit>();
            CreateMap<ProductionUnit, ProductionUnitResult>();
            #endregion

            #region Process
            CreateMap<AddingProcessInput, Process>();
            CreateMap<Process, ProcessesResult>();
            CreateMap<Process, CurrentProcessResult>();
            #endregion

            #region StdOper
            CreateMap<StdOperInput, StdOper>();
            CreateMap<StdOper, StdOperResult>();
            #endregion

            #region Attr
            CreateMap<AttrInput, Attr>();
            CreateMap<Attr, AttrResult>();
            #endregion

            #region StdOperAttr
            CreateMap<StdOperAttrInput, StdOperAttr>();
            CreateMap<StdOperAttr, StdOperAttrResult>();
            #endregion

            #region StdOperEntLink
            CreateMap<StdOperEntLinkInput, StdOperEntLink>();
            CreateMap<StdOperEntLink, StdOperEntLinkResult>();
            #endregion

            #region StdOperStepGrp
            CreateMap<StdOperStepGrpInput, StdOperStepGrp>();
            CreateMap<StdOperStepGrp, StdOperStepGrpResult>();
            #endregion

            #region StdOperStep
            CreateMap<StdOperStepInput, StdOperStep>();
            CreateMap<StdOperStep, StdOperStepResult>();
            #endregion

            #region ProcessRoute
            CreateMap<AddProcessRouteInput, ProcessRoute>();
            CreateMap<ProcessRoute, ProcessRoutesResult>();
            CreateMap<ProcessRoute, ProcessRouteResult>();
            CreateMap<StdOperEntRouteInput, StdOperEntRoute>();
            CreateMap<StdOperEntRoute, StdOperEntRouteResult>();
            #endregion

            #region Oper
            CreateMap<Oper, OperResult>();
            CreateMap<Oper, OpersResult>();
            #endregion

            #region OperEntLink
            CreateMap<OperEntLinkInput, OperEntLink>();
            CreateMap<OperEntLink, OperEntLinkResult>();
            #endregion

            #region OperAttr
            CreateMap<OperAttrInput, OperAttr>();
            CreateMap<OperAttr, OperAttrResult>();
            #endregion

            #region OperStepGrp
            CreateMap<OperStepGrpInput, OperStepGrp>();
            CreateMap<OperStepGrp, OperStepGrpResult>();
            #endregion

            #region OperStep
            CreateMap<OperStepInput, OperStep>();
            CreateMap<OperStep, OperStepResult>();
            #endregion

            #region BomItemOperLink
            CreateMap<BomItemOperLinkInput, BomItemOperLink>();
            CreateMap<BomItemOperLink, BomItemOperLinkResult>();
            #endregion

            #region JobState
            CreateMap<JobState, JobStatesResult>();

            #endregion

            #region Wo
            CreateMap<AddWoInput, Wo>();
            CreateMap<Wo, WoResult>();
            CreateMap<Wo, WosResult>();
            CreateMap<Process, ProcessForWoResult>();
            CreateMap<Material, MaterialForWoResult>();
            #endregion

            #region Job
            CreateMap<Job, JobResult>();
            CreateMap<Job, JobDetailsResult>();
            CreateMap<AddingJobInput, Job>();
            CreateMap<Job, WoJobRoutesResult>();
            #endregion

            #region JobStepGrp
            CreateMap<JobStepGrpInput, JobStepGrp>();
            CreateMap<JobStepGrp, JobStepGrpResult>();
            #endregion

            #region JobStep
            CreateMap<JobStepInput, JobStep>();
            CreateMap<JobStep, JobStepResult>();
            #endregion

            #region WoFlow
            CreateMap<AddingItemProdInput, ItemProd>();
            CreateMap<Job, EntJobsResult>();
            CreateMap<ItemProd, ItemProdResult>();
            CreateMap<JobBom, RunningJobBomResult>();
            CreateMap<JobStepGrp, RunningJobStepGrpResult>();
            CreateMap<AddingItemConsInput, ItemCons>();
            #endregion

            #region SampleFreq
            CreateMap<AddingSampleFreqInput, SampleFreq>();
            CreateMap<SampleFreq, SampleFreqResult>();
            CreateMap<SampleFreq, SampleFreqDetailResult>();
            #endregion

            #region
            CreateMap<SamplePlan, SamplePlanResult>();
            #endregion

            #region Characteristic
            CreateMap<AddingCharacteristicInput, Characteristic>();
            CreateMap<Characteristic, CharacteristicResult>();
            CreateMap<Characteristic, CharacteristicDetailResult>();
            CreateMap<Characteristic, CharacteristicResultForQmSpec>();
            #endregion

            #region
            CreateMap<QmSpec, QmSpecResult>();
            #endregion

            #region SpcRule
            CreateMap<SpcRule, SpcRuleResult>();
            #endregion
        }
    }
}